/**
 * 
 */
package com.cmcc.volte.xdr.sequence;

import java.util.Comparator;

public class ComparatorArrow implements Comparator<Object> {

	public int compare(Object arg0, Object arg1) {
		Arrow arrow0 = (Arrow) arg0;
		Arrow arrow1 = (Arrow) arg1;
		// 首先比较年龄，如果年龄相同，则比较名字
		int flag = String.valueOf(arrow0.getDateTime_s()).compareTo(String.valueOf(arrow1.getDateTime_s()));
		if (flag == 0) {
			//需要将两个毫秒数据统一为9位长度的字符串，在进行比较
			String dtns0 = java.lang.Math.abs(arrow0.getDateTime_ns())+"";
			if(dtns0.length() != 9){
				String qianbuwei = ""; //如果纳秒长度不够9位则前补0
				for (int i = 0; i < 9-dtns0.length(); i++) {
					qianbuwei = qianbuwei+"0";
				}
				dtns0 = qianbuwei + dtns0;
			}
			String dtns1 = java.lang.Math.abs(arrow1.getDateTime_ns())+"";
			if(dtns1.length() != 9){
				String qianbuwei = ""; //如果纳秒长度不够9位则前补0
				for (int i = 0; i < 9-dtns1.length(); i++) {
					qianbuwei = qianbuwei+"0";
				}
				dtns1 = qianbuwei + dtns1;
			}
			return dtns0.compareTo(dtns1);
		} else {
			return flag;
		}
	}
}